home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / Draw / Sources / PrintHdl.cpp < prev    next >
Encoding:
Text File  |  1996-09-17  |  3.2 KB  |  107 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                PrintHdl.cpp
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Author:                Henri Lamiraux
  7. //
  8. //    Copyright:            (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #include "ODFDraw.hpp"
  13.  
  14. #ifndef PRINTHDL_H
  15. #include "PrintHdl.h"
  16. #endif
  17.  
  18. #ifndef DRAWFRM_H
  19. #include "DrawFrm.h"
  20. #endif
  21.  
  22. #ifndef DRAWCONT_H
  23. #include "DrawCont.h"
  24. #endif
  25.  
  26. #ifndef FWPART_H
  27. #include "FWPart.h"
  28. #endif
  29.  
  30. #ifndef FWPRESEN_H
  31. #include "FWPresen.h"
  32. #endif
  33.  
  34. //========================================================================================
  35. // RunTime Info
  36. //========================================================================================
  37.  
  38. #ifdef FW_BUILD_MAC
  39. #pragma segment odfdrawframes
  40. #endif
  41.  
  42. //========================================================================================
  43. // CDrawPrintHandler
  44. //========================================================================================
  45.  
  46. //----------------------------------------------------------------------------------------
  47. // CDrawPrintHandler::CDrawPrintHandler
  48. //----------------------------------------------------------------------------------------
  49. //    FALSE means I will be drawing the embedded frames. No need for the printhandler to do it
  50.  
  51. CDrawPrintHandler::CDrawPrintHandler(Environment* ev, CDrawFrame* frame, CDrawPartContent* content, FW_CPresentation* presentation) :
  52.     FW_CPrintHandler(content->GetPart(ev), frame, FALSE),
  53.     fDrawFrame(frame),
  54.     fPartContent(content),
  55.     fPrintPresentation(presentation)
  56. {
  57. }
  58.  
  59. //----------------------------------------------------------------------------------------
  60. // CDrawPrintHandler::~CDrawPrintHandler
  61. //----------------------------------------------------------------------------------------
  62.  
  63. CDrawPrintHandler::~CDrawPrintHandler()
  64. {
  65. }
  66.  
  67. //----------------------------------------------------------------------------------------
  68. //    CDrawPrintHandler::IsCurrentlyPrintable
  69. //----------------------------------------------------------------------------------------
  70.  
  71. FW_Boolean CDrawPrintHandler::IsCurrentlyPrintable(Environment* ev) const
  72. {
  73. FW_UNUSED(ev);
  74.     return !fPartContent->IsEmpty();
  75. }
  76.  
  77. //----------------------------------------------------------------------------------------
  78. //    CDrawPrintHandler::GetPrintContentExtent
  79. //----------------------------------------------------------------------------------------
  80.  
  81. void CDrawPrintHandler::GetPrintContentExtent(Environment *ev, FW_CPoint& extent) const
  82. {
  83. #ifndef FW_DEBUG
  84. FW_UNUSED(ev);
  85. #endif
  86.     // We only enable print command if there is anything to print
  87.     FW_ASSERT(IsCurrentlyPrintable(ev));
  88.  
  89.     // Go through all the shapes and determine their bounds
  90.     extent.Set(FW_kFixed0, FW_kFixed0);
  91.     CDrawContentShapeIterator ite(fPartContent);
  92.     for (CBaseShape* theShape = ite.First(); ite.IsNotComplete(); theShape = ite.Next())
  93.     {
  94.         FW_CRect updateBox;
  95.         theShape->GetUpdateBox(updateBox);
  96.  
  97.         if (updateBox.right > extent.x)
  98.             extent.x = updateBox.right;
  99.         
  100.         if (updateBox.bottom > extent.y)
  101.             extent.y = updateBox.bottom;
  102.     }
  103.     
  104.     FW_ASSERT(extent.x != FW_kFixed0);
  105.     FW_ASSERT(extent.y != FW_kFixed0);
  106. }
  107.